/*     */ package com.qmsk.business.store.instockbill.controller;
/*     */ 
/*     */ import com.qmsk.business.store.instockbill.dao.InStockBillDAO;
/*     */ import com.qmsk.business.store.instockbill.service.InStockBillService;
/*     */ import com.qmsk.business.store.instockdtl.dao.InStockDtlDAO;
/*     */ import com.utils.basic.MapUtils;
/*     */ import com.utils.gson.in.GsonHeadOneRow;
/*     */ import com.utils.gson.in.ParserDataSetJson;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.sql.SQLException;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"inStore"})
/*     */ public class InStockBillController
/*     */ {
/*  33 */   private static final Logger logger = Logger.getLogger(InStockBillController.class);
/*     */ 
/*     */   @Autowired
/*     */   private InStockBillService service;
/*     */ 
/*     */   @Autowired
/*     */   private InStockBillDAO dao;
/*     */ 
/*     */   @Autowired
/*     */   private InStockDtlDAO dtlDao;
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/barCode/{barCode}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOfBarCode(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId, @PathVariable("barCode") String id)
/*     */   {
/*     */     try {
/*  48 */       Map params = new HashMap();
/*  49 */       MapUtils.addToMap(params, "barCode", id);
/*  50 */       MapUtils.addToMap(params, "shopId", shopId);
/*  51 */       GsonEbRst gsonEbRst = this.dtlDao.getGsonOfGoods(params, Integer.valueOf(0), Short.valueOf((short) 1));
/*  52 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/*  54 */       logger.error(e);
/*  55 */       ResponseUtils.setErrorMsgResponse(
/*  56 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/goodsNo/{goodsNo}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOfGoodsNo(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId, @PathVariable("goodsNo") String goodsNo)
/*     */   {
/*     */     try
/*     */     {
/*  65 */       Map params = new HashMap();
/*  66 */       MapUtils.addToMap(params, "goodsCode", goodsNo);
/*  67 */       MapUtils.addToMap(params, "shopId", shopId);
/*  68 */       GsonEbRst gsonEbRst = this.dtlDao.getGsonOfGoods(params, Integer.valueOf(0), Short.valueOf((short) 1));
/*  69 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/*  71 */       logger.error(e);
/*  72 */       ResponseUtils.setErrorMsgResponse(
/*  73 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/goodsParam/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOfGoodsParam(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*     */     try
/*     */     {
/*  83 */       Map params = new HashMap();
/*  84 */       MapUtils.addToMap(params, "goodsCode", 
/*  85 */         RequestUtils.getString(request, "goodsCode"));
/*  86 */       MapUtils.addToMap(params, "barCode", 
/*  87 */         RequestUtils.getString(request, "barCode"));
/*  88 */       MapUtils.addPercentToMap(params, "goodsName", 
/*  89 */         RequestUtils.getString(request, "goodsName"));
/*  90 */       MapUtils.addToMap(params, "shopId", 
/*  91 */         RequestUtils.getLong(request, "shopId"));
/*  92 */       GsonEbRst gsonEbRst = this.dtlDao.getGsonOfGoods(params, nPageIdx, 
/*  93 */         nPageSize);
/*  94 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/*  96 */       logger.error(e);
/*  97 */       ResponseUtils.setErrorMsgResponse(
/*  98 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/barCodeInStore/{barCode}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOfBarCodeInStore(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId, @PathVariable("barCode") String id)
/*     */   {
/*     */     try
/*     */     {
/* 110 */       Map params = new HashMap();
/* 111 */       MapUtils.addToMap(params, "barCode", id);
/* 112 */       MapUtils.addToMap(params, "shopId", shopId);
/* 113 */       GsonEbRst gsonEbRst = this.dtlDao.getGsonOfGoodsInStore(params, Integer.valueOf(0), 
/* 114 */         Short.valueOf((short) 1));
/* 115 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/* 117 */       logger.error(e);
/* 118 */       ResponseUtils.setErrorMsgResponse(
/* 119 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/goodsNoInStore/{goodsNo}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOfGoodsNoInStore(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId, @PathVariable("goodsNo") String goodsNo)
/*     */   {
/*     */     try
/*     */     {
/* 131 */       Map params = new HashMap();
/* 132 */       MapUtils.addToMap(params, "goodsCode", goodsNo);
/* 133 */       MapUtils.addToMap(params, "shopId", shopId);
/* 134 */       GsonEbRst gsonEbRst = this.dtlDao.getGsonOfGoodsInStore(params, Integer.valueOf(0), 
/* 135 */         Short.valueOf((short) 1));
/* 136 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/* 138 */       logger.error(e);
/* 139 */       ResponseUtils.setErrorMsgResponse(
/* 140 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/goodsInStore/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOfGoodsInStore(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*     */     try
/*     */     {
/* 153 */       Map params = new HashMap();
/* 154 */       MapUtils.addToMap(params, "goodsCode", 
/* 155 */         RequestUtils.getString(request, "goodsCode"));
/* 156 */       MapUtils.addToMap(params, "barCode", 
/* 157 */         RequestUtils.getString(request, "barCode"));
/* 158 */       MapUtils.addPercentToMap(params, "goodsName", 
/* 159 */         RequestUtils.getString(request, "goodsName"));
/* 160 */       MapUtils.addToMap(params, "shopId", 
/* 161 */         RequestUtils.getLong(request, "shopId"));
/* 162 */       if (params.get("shopId") == null) {
/* 163 */         throw new NullPointerException();
/*     */       }
/* 165 */       GsonEbRst gsonEbRst = this.dtlDao.getGsonOfGoodsInStore(params, 
/* 166 */         nPageIdx, nPageSize);
/* 167 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/* 169 */       logger.error(e);
/* 170 */       ResponseUtils.setErrorMsgResponse(
/* 171 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/opt/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOptShopId(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/* 180 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/* 182 */       Map params = new HashMap();
/* 183 */       MapUtils.addToMap(params, "id", RequestUtils.getLong(request, "id"));
/* 184 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(params, nPageIdx, nPageSize);
/* 185 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/* 187 */       logger.error(e);
/* 188 */       ResponseUtils.setErrorMsgResponse(
/* 189 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/id/{id}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListId(HttpServletRequest request, HttpServletResponse response, @PathVariable("id") Long id)
/*     */   {
/*     */     try {
/* 197 */       GsonEbRst gsonEbRst = this.dao.getGsonOfId(id);
/* 198 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/* 200 */       logger.error(e);
/* 201 */       ResponseUtils.setErrorMsgResponse(
/* 202 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/dtlId/{id}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListDtlId(HttpServletRequest request, HttpServletResponse response, @PathVariable("id") Long id)
/*     */   {
/*     */     try {
/* 210 */       GsonEbRst gsonEbRst = this.dtlDao.getGsonOfId(id);
/* 211 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/* 213 */       logger.error(e);
/* 214 */       ResponseUtils.setErrorMsgResponse(
/* 215 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/params/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListParams(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/* 224 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/* 226 */       Map params = new HashMap();
/* 227 */       MapUtils.addToMap(params, "inNo", 
/* 228 */         RequestUtils.getString(request, "inNo"));
/* 229 */       MapUtils.addToMap(params, "linkNo", 
/* 230 */         RequestUtils.getString(request, "linkNo"));
/* 231 */       MapUtils.addPercentToMap(params, "maker", 
/* 232 */         RequestUtils.getString(request, "maker"));
/* 233 */       MapUtils.addPercentToMap(params, "stocker", 
/* 234 */         RequestUtils.getString(request, "stocker"));
/* 235 */       MapUtils.addPercentToMap(params, "checker", 
/* 236 */         RequestUtils.getString(request, "checker"));
/* 237 */       MapUtils.addToMap(params, "inTpId", 
/* 238 */         RequestUtils.getString(request, "inTpId"));
/* 239 */       MapUtils.addToMap(params, "status", 
/* 240 */         RequestUtils.getInt(request, "status"));
/* 241 */       MapUtils.addToMap(params, "dtCreateStart", 
/* 242 */         RequestUtils.getDate(request, "dtCreateStart"));
/* 243 */       MapUtils.addToMap(params, "dtCreateEnd", 
/* 244 */         RequestUtils.getDate(request, "dtCreateEnd"));
/* 245 */       MapUtils.addToMap(params, "dtInStoreStart", 
/* 246 */         RequestUtils.getDate(request, "dtInStoreStart"));
/* 247 */       MapUtils.addToMap(params, "dtInStoreEnd", 
/* 248 */         RequestUtils.getDate(request, "dtInStoreEnd"));
/*     */ 
/* 250 */       GsonEbRst gsonEbRst = this.dao.getGsonOfInStoreParams(params, nPageIdx, 
/* 251 */         nPageSize);
/* 252 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/* 254 */       logger.error(e);
/* 255 */       ResponseUtils.setErrorMsgResponse(
/* 256 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"insert/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId)
/*     */   {
/*     */     try
/*     */     {
/* 274 */       int nResult = 0;
/* 275 */       Long id = null;
/* 276 */       String inNo = null;
/* 277 */       String sData = RequestUtils.getStringOfData(request);
/* 278 */       String sInstoreDtl = RequestUtils.getString(request, "inStoreDtl");
/* 279 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 280 */       ParserDataSetJson p_dtl = ParserDataSetJson.fromString(sInstoreDtl);
/*     */ 
/* 282 */       if ((p != null) && (p.isExistsInsertRows())) {
/* 283 */         inNo = this.dao.getMaxBillNo(shopId);
/* 284 */         for (GsonHeadOneRow g : p.getListInsertRows()) {
/* 285 */           g.autoAddHeadData("inNo", inNo);
/*     */         }
/* 287 */         nResult = this.dao.applyUpdates(p, "id");
/* 288 */         if (nResult > 0) {
/* 289 */           id = (Long)((GsonHeadOneRow)p.getListInsertRows().get(0))
/* 290 */             .getValueOfName("id");
/*     */         }
/*     */       }
/*     */ 
/* 294 */       if (id != null) {
/* 295 */         for (GsonHeadOneRow r : p_dtl.getListInsertRows()) {
/* 296 */           r.autoAddHeadData("id", id);
/*     */         }
/* 298 */         nResult = this.dtlDao.applyUpdates(p_dtl);
/*     */       }
/* 300 */       if (nResult > 0) {
/* 301 */         DbConnection.commit();
/* 302 */         if (id != null) {
/* 303 */           String[] heads = { "id", "inNo" };
/* 304 */           Object[] datas = { id, inNo };
/* 305 */           ResponseUtils.toGsonEbRst(heads, datas, response);
/* 306 */           return; }
/* 307 */         ResponseUtils.setSqlResultResponse(nResult, 
/* 308 */           RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 309 */           response);
/*     */ 
/* 311 */         return; }
/* 312 */       DbConnection.rollback();
/* 313 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 314 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 315 */         response);
/*     */     }
/*     */     catch (Exception e) {
/* 318 */       logger.error(e);
/* 319 */       DbConnection.rollback();
/* 320 */       ResponseUtils.setErrorMsgResponse(
/* 321 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 322 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"edit/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void edit(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId)
/*     */   {
/*     */     try {
/* 331 */       int nResult = 0;
/* 332 */       String sData = RequestUtils.getStringOfData(request);
/* 333 */       String sInstoreDtl = RequestUtils.getString(request, "inStoreDtl");
/* 334 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 335 */       ParserDataSetJson p_dtl = ParserDataSetJson.fromString(sInstoreDtl);
/*     */ 
/* 337 */       if ((p != null) && (p.isExistsUpdateRows())) {
/* 338 */         nResult = this.dao.applyUpdates(p);
/*     */       }
/* 340 */       if (p_dtl != null) {
/* 341 */         nResult += this.dtlDao.applyUpdates(p_dtl);
/*     */       }
/*     */ 
/* 344 */       if (nResult > 0)
/* 345 */         DbConnection.commit();
/*     */       else {
/* 347 */         DbConnection.rollback();
/*     */       }
/* 349 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 350 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 351 */         response);
/*     */     } catch (Exception e) {
/* 353 */       logger.error(e);
/* 354 */       DbConnection.rollback();
/* 355 */       ResponseUtils.setErrorMsgResponse(
/* 356 */         RequestUtils.getSqlUpdateDataErrorMessage(request) + ":" + 
/* 357 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"del/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 373 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 375 */       String[] strParams = id.split(",");
/* 376 */       int nResult = 0;
/*     */ 
/* 378 */       nResult = this.dtlDao.deleteByInId(strParams);
/*     */ 
/* 380 */       if (nResult > 0) {
/* 381 */         nResult = this.dao.deleteParams(strParams);
/*     */       }
/* 383 */       if (nResult > 0)
/* 384 */         DbConnection.commit();
/*     */       else {
/* 386 */         DbConnection.rollback();
/*     */       }
/* 388 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 389 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 390 */         response);
/*     */     } catch (Exception e) {
/* 392 */       DbConnection.rollback();
/* 393 */       logger.error(e);
/* 394 */       ResponseUtils.setErrorMsgResponse(
/* 395 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 396 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"check/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void check(HttpServletRequest request, HttpServletResponse response)
/*     */     throws SQLException
/*     */   {
/* 414 */     int nResult = 0;
/* 415 */     Long id = RequestUtils.getLong(request, "id");
/*     */     try {
/* 417 */       nResult = this.service.check(id, response).intValue();
/* 418 */       if (nResult > 0)
/* 419 */         DbConnection.commit();
/*     */       else {
/* 421 */         DbConnection.rollback();
/*     */       }
/* 423 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 424 */         RequestUtils.getSqlUpdateDataErrorMessage(request), 
/* 425 */         response);
/*     */     } catch (Exception e) {
/* 427 */       DbConnection.rollback();
/* 428 */       logger.error(e);
/* 429 */       ResponseUtils.setErrorMsgResponse(
/* 430 */         RequestUtils.getSqlUpdateDataErrorMessage(request) + ":" + 
/* 431 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.store.instockbill.controller.InStockBillController
 * JD-Core Version:    0.5.3
 */